function scratchJsFlashCallback(n,t,i){"undefined"!=typeof i?(n=window[n],"function"==typeof n&&n(i,scratchJsFlashArray[t])):(i=window[n],"function"==typeof i&&i(scratchJsFlashArray[t]))}function createScratchCard(n){function ht(){clearTimeout(n.resizeTrigger);n.resizeTrigger=setTimeout(nt,100)}function nt(){window.removeEventListener("resize",nt);tt(!1);createScratchCard(n)}function ct(){if("undefined"==typeof n.foreground||n.hasEnded)return!1;"#"!==n.foreground.charAt(0)||4!=n.foreground.length&&7!=n.foreground.length?(i.topImage.crossOrigin="anonymous",i.topImage.src=n.foreground,i.topImage.onload=function(){"undefined"!=typeof n.scratchedOverlay?(e.drawImage(i.topImage,0,0,u,f),e.globalCompositeOperation="destination-out",e.drawImage(n.scratchedOverlay,0,0,u,f)):e.drawImage(i.topImage,0,0,u,f);ft()}):(e.fillStyle=n.foreground,e.fillRect(0,0,u,f),"undefined"!=typeof n.scratchedOverlay&&(e.globalCompositeOperation="destination-out",e.drawImage(n.scratchedOverlay,0,0,u,f)),ft());"undefined"!=typeof n.percent&&(i.endAt=n.percent);"undefined"!=typeof n.coin?(i.coinImage.src=n.coin,i.coinImage.onload=function(){d=i.coinImage.width*v;g=i.coinImage.height*v;o.style.width=d+"px";o.style.height=g+"px";o.style.background='url("'+n.coin+'") no-repeat left top';o.style.backgroundSize="100%";r.style.cursor="none";o.style.position="absolute";o.style.display="none";o.style.zIndex="9000";o.style.top=0;o.style.left=0;o.style.pointerEvents="none";it(o)}):t.style.cursor=i.defaultCursor;"undefined"!=typeof n.thickness&&(i.thickness=n.thickness);"undefined"!=typeof n.counter&&(i.counter=n.counter,a=window[n.counter]);document.body.addEventListener("touchstart",function(){ot=!0},!1);t.addEventListener("mousedown",s);t.addEventListener("mousemove",s);document.addEventListener("mouseup",h);t.addEventListener("touchstart",s);t.addEventListener("touchmove",s);document.addEventListener("touchend",h);t.addEventListener("mouseover",y);t.addEventListener("mouseout",p);t.addEventListener("mousemove",w)}function ut(n){for(var t=0,i=0;n;)t+=n.offsetLeft+n.clientLeft,i+=n.offsetTop+n.clientTop,n=n.offsetParent;return{x:t,y:i}}function ft(){window.addEventListener("resize",ht);r.appendChild(t);r.appendChild(o);r.style.background='url("'+n.background+'") center center no-repeat';r.style.backgroundSize="100%"}function s(n){var o=!1;if("touchmove"==n.type?(n.preventDefault(),o=!1):("mousedown"==n.type||"touchstart"==n.type)&&(o=isMouseDown=!0),et(!0),isMouseDown){var s=n.pageX-this.offsetLeft,u=n.pageY-this.offsetTop,f=ut(r),s=n.pageX-f.x,u=n.pageY-f.y;("touchmove"==n.type||"touchstart"==n.type)&&(st=20,u=n.touches[0],s=u.pageX-f.x,u=u.pageY-f.y);e.save();e.globalCompositeOperation="destination-out";e.beginPath();e.arc(s,u,i.thickness*v,0,2*Math.PI,!1);e.closePath();e.fillStyle="rgba(0, 0, 0, 1)";e.fill();e.restore();("touchmove"==n.type||"touchstart"==n.type||"touchend"==n.type)&&(t.style.marginRight="1px",t.style.marginRight="0px");parseInt(et(o))>=i.endAt&&tt(!0)}}function tt(u){t.removeEventListener("mousedown",s);t.removeEventListener("mousemove",s);document.removeEventListener("mouseup",h);t.removeEventListener("mouseover",y);t.removeEventListener("mouseout",p);t.removeEventListener("mousemove",w);t.removeEventListener("touchstart",s);t.removeEventListener("touchmove",s);document.removeEventListener("touchend",h);r.addEventListener("touchmove",function(n){return n.preventDefault(),!1});u&&!n.hasEnded?(n.hasEnded=!0,r.style.setProperty("cursor","default","important"),t.style.setProperty("cursor","default","important"),o.style.display="none",delete n.scratchedOverlay,r.innerHTML="",0!=i.counter&&"function"==typeof a&&a(l,n),u=window[n.callback],"function"==typeof u&&u(n)):u||n.hasEnded||(0!=b&&(r.style.width=b),0!=k&&(r.style.height=k),n.scratchedOverlay=lt(),r.style.backgroundImage="none",r.innerHTML="")}function et(t){if(0==at++%st||t){t=0;for(var o=e.getImageData(0,0,u,f).data,r=0,s=o.length-20;r<\/object>':(t.appendChild(u),t.appendChild(e),t.appendChild(o),t.appendChild(f),n.container.appendChild(t));n.locked=!0;n.container.lock=function(i){"undefined"==typeof i&&(i=n.locked);n.locked=!n.locked;t.lock(i)};n.container.restart=function(){t.restart()};n.container.clean=function(){t.clean()}},i.bottomImage.src=n.background),!1;r.innerHTML="Your browser does not support HTML5 canvas tag."}if("undefined"!=typeof n.container)r=n.container,u=r.offsetWidth,f=r.offsetHeight,r.style.setProperty("position","relative","important"),r.style.setProperty("padding","0","important"),it(r);else return!1;if("undefined"==typeof n.background||n.hasEnded)return!1;i.bottomImage.onload=function(){0!=u&&0==f?(k="auto",f=u/i.bottomImage.width*i.bottomImage.height,r.style.height=f+"px"):0==u&&0!=f&&(b="auto",u=f/i.bottomImage.height*i.bottomImage.width,r.style.width=u+"px");0==u*f&&(k=b="auto",u=i.bottomImage.width,f=i.bottomImage.height,r.style.width=u+"px",r.style.height=f+"px");"undefined"==typeof n.responsiveRatio?n.responsiveRatio=u/i.bottomImage.width:v=u/i.bottomImage.width;v=u/i.bottomImage.width/n.responsiveRatio;t.width=u;t.height=f;it(t);ct()};i.bottomImage.src=n.background;t=document.createElement("canvas");t.className="scratchcard-Overlay";e=t.getContext("2d");e.translate(0,0);o=document.createElement("div");o.className="scratchcard-Cursor";d=0;g=0;document.addEventListener("touchstart",c);document.addEventListener("touchmove",c);document.addEventListener("touchend",c);n.locked=!1;n.container.lock=function(r){"undefined"!=typeof r&&(n.locked=!r);n.locked?(t.addEventListener("mousedown",s),t.addEventListener("mousemove",s),document.addEventListener("mouseup",h),t.addEventListener("mouseover",y),t.addEventListener("mouseout",p),t.addEventListener("mousemove",w),t.addEventListener("touchstart",s),t.addEventListener("touchmove",s),document.addEventListener("touchend",h),"undefined"==typeof n.coin&&(t.style.cursor=i.defaultCursor)):(t.removeEventListener("mousedown",s),t.removeEventListener("mousemove",s),document.removeEventListener("mouseup",h),t.removeEventListener("mouseover",y),t.removeEventListener("mouseout",p),t.removeEventListener("mousemove",w),t.removeEventListener("touchstart",s),t.removeEventListener("touchmove",s),document.removeEventListener("touchend",h),t.style.cursor="default");n.locked=!n.locked};n.container.restart=function(){n.hasEnded=!1;tt(!1);n.scratchedOverlay=void 0;window.removeEventListener("resize",nt);createScratchCard(n)};n.container.clean=function(){n.hasEnded=!0;n.container.lock(!0);delete n.scratchedOverlay;r.innerHTML="";r.style.setProperty("cursor","default")}}function SendPicture(){$("#loading-icon").removeClass("hidden");var n=new FormData,t=$("#upload-image")["0"].files[0],i=$("input[name=__RequestVerificationToken]").val();n.append("FileUpload",t);n.append("__RequestVerificationToken",i);$("#btn-upload-camera-image").addClass("btn-disabled");$("#upload-camera-image-preview").addClass("btn-disabled");$.ajax({url:"/Home/UploadPicture",type:"POST",data:n,processData:!1,contentType:!1,xhr:function(){var n=new window.XMLHttpRequest;return n.upload.addEventListener("progress",function(n){if(n.lengthComputable){var t=n.loaded/n.total;t=parseInt(t*100);$("#upload-indicator").html(Math.round(t)+"%")}},!1),n},success:function(){numberOfStampsWonThisGame<1&&incrementStampsAndEntries();changePage("#todays-draw-page")}})}function buttonAnimation(n,t){n.addClass("cbutton");setTimeout(function(){t()},buttonAnimationLength);setTimeout(function(){n.removeClass("cbutton")},buttonResetButtonLength)}function moveToPage(n){$.mobile.changePage(n,{transition:"fade",reverse:!1,changeHash:!1},!0,!0)}function gamePage(){moveToPage(currentPage)}function changePage(n){currentPage=n;moveToPage(n);var t=new FormData,i=$("input[name=__RequestVerificationToken]").val();t.append("page",n);t.append("__RequestVerificationToken",i);$.ajax({type:"POST",url:"/Home/UpdateLocation/",processData:!1,contentType:!1,data:t,success:function(){},error:function(){}})}function updateSettings(){var t=$("#user-setting-form"),i=new FormData,r=$("input[name=__RequestVerificationToken]").val(),n;i.append("__RequestVerificationToken",r);n=$("#user-setting-form").serialize();t.valid()&&$.ajax({url:"/Home/Settings",type:"POST",data:n,success:function(n){n?$("#settings-saved").popup("open"):$("#mobile-error").text("Sorry, this mobile number has already been registered")}})}function initFacebookShare(){$("#shareBtn").click(function(){FB.ui({method:"feed",link:"http://shopandwin.co.uk",caption:"I've just won a voucher using SPAR Shop and Win!",picture:fbPic,callbackurl:"http://shopandwin.co.uk"},function(n){if(typeof n!="undefined"){var t={PostId:n.post_id};$.ajax({type:"POST",url:"/Home/ConfirmFacebookShare",dataType:"json",contentType:"application/json; charset=utf-8",data:JSON.stringify(t),success:function(){incrementStampsAndEntries()},error:function(){}});changePage("#selfie-page")}})})}function stamps(){stamping=setInterval(function(){updateStamps()},1500)}function updateStamps(){numberOfStampsSeen150?countdownSpeed=10:grandprizenumber>100?countdownSpeed=12:grandprizenumber>50?countdownSpeed=14:grandprizenumber>25?countdownSpeed=16:grandprizenumber>10?countdownSpeed=18:grandprizenumber<5&&(countdownSpeed+=12);countdownIntervalRate=countdownSpeed*10;numberOfGrandPrizeEntries++;var n=("00"+numberOfGrandPrizeEntries).slice(-3);change_custom_state(c2,n);setTimeout(caller,countdownIntervalRate)}}function caller(){updateEntryCounter()}function slideClicked(n){var t=$(n).find(".slide"),i=$(t).data("value"),r,u;i!==undefined&&(r=parseInt(prizes[rollStartImageIndex][2]),$(t).hasClass("selected")?(u=carousel.indexOf(i),u>-1&&(carousel.splice(u,1),$(t).removeClass("selected"),$(".win-carousel-close").addClass("btn-disabled"))):carousel.length===r||(carousel.push(i),$(t).addClass("selected"),carousel.length===r&&$(".win-carousel-close").removeClass("btn-disabled")))}function SendReward(){var n=new FormData,t=$("input[name=__RequestVerificationToken]").val();n.append("__RequestVerificationToken",t);n.append("value",prizes[rollStartImageIndex][2]);n.append("data",carousel.toString());$.ajax({type:"POST",url:"/Home/CollectPrize/",processData:!1,contentType:!1,data:n,success:function(){},error:function(){}})}function PrizeCollected(){$(".three-d-large").off("click");visibleStamps=0;carousel=[];$(".slide").removeClass("selected");$(".win-carousel-close").addClass("btn-disabled");$("#win-grand-prize-entries-close").addClass("btn-disabled");prizeImageSwap="/Content/images/assets/claim-prize.png";$(".stamps .stamped").removeClass("stamped").removeClass("img-move");for(var n=1;n<5;n++)$(".stamp-"+n+" img").attr("src","/Content/images/assets/spar-logo.png");clearInterval(prizeFlashTimer);roll();stamps()}function flashPrize(){var n=$("#prize-large .front"),t=prizeImageSwap;prizeImageSwap=n.attr("src");n.attr("src",t);get50()}function scratchComplete(){isWin?scratchWin():scratchLoose()}function scratchLoose(){setTimeout(function(){changePage("#scratch-card-results-page")},1e3)}function scratchWin(){setTimeout(function(){changePage("#scratch-card-results-page")},6e3);setTimeout(function(){sparkle()},1500);$("#overlay").removeClass("hidden");$("#container").removeClass("hidden");centerX=$("#scratch-card-page").width()/2;centerY=$("#scratch-card-page").height()/2;newX=centerX;newY=centerY;sparkles=Sketch.create({fullscreen:!0,container:document.getElementById("container")});sparkles.spawn=function(n,t){particles.length>=MAX_PARTICLES&&pool.push(particles.shift());particle=pool.length?pool.pop():new Particle;particle.init(n,t,random(5,30));particle.wander=random(.5,2);particle.color=random(COLOURS);particle.drag=random(.9,.99);theta=random(TWO_PI);force=random(2,8);particle.vx=sin(theta)*force;particle.vy=cos(theta)*force;particles.push(particle)};sparkles.update=function(){for(var t,n=particles.length-1;n>=0;n--)t=particles[n],t.alive?t.move():pool.push(particles.splice(n,1)[0])};sparkles.draw=function(){sparkles.globalCompositeOperation="lighter";for(var n=particles.length-1;n>=0;n--)particles[n].draw(sparkles)};sparkles.setup=function(){canvas1=document.querySelector(".sketch");fitToContainer(canvas1)}}function sparkle(){requestAnimationFrame(update)}function Particle(n,t,i){this.init(n,t,i)}function fitToContainer(n){n.style.width="100%";n.style.height="100%";n.width=n.offsetWidth;n.height=n.offsetHeight;centerX=$("#scratch-card-page").width()/2;centerY=$("#scratch-card-page").height()/2}function update(n){var i,t,r,u,f;for(start||(start=n),i=Math.min((n-start)/4e3,1),t=increment;t0&&t-1 in n}function ui(n,t,r){if(i.isFunction(t))return i.grep(n,function(n,i){return!!t.call(n,i,n)!==r});if(t.nodeType)return i.grep(n,function(n){return n===t!==r});if("string"==typeof t){if(re.test(t))return i.filter(t,n,r);t=i.filter(t,n)}return i.grep(n,function(n){return i.inArray(n,t)>=0!==r})}function hr(n,t){do n=n[t];while(n&&1!==n.nodeType);return n}function ee(n){var t=fi[n]={};return i.each(n.match(h)||[],function(n,i){t[i]=!0}),t}function cr(){u.addEventListener?(u.removeEventListener("DOMContentLoaded",a,!1),n.removeEventListener("load",a,!1)):(u.detachEvent("onreadystatechange",a),n.detachEvent("onload",a))}function a(){(u.addEventListener||"load"===event.type||"complete"===u.readyState)&&(cr(),i.ready())}function yr(n,t,r){if(void 0===r&&1===n.nodeType){var u="data-"+t.replace(vr,"-$1").toLowerCase();if(r=n.getAttribute(u),"string"==typeof r){try{r="true"===r?!0:"false"===r?!1:"null"===r?null:+r+""===r?+r:ar.test(r)?i.parseJSON(r):r}catch(f){}i.data(n,t,r)}else r=void 0}return r}function ei(n){for(var t in n)if(("data"!==t||!i.isEmptyObject(n[t]))&&"toJSON"!==t)return!1;return!0}function pr(n,t,r,u){if(i.acceptData(n)){var s,e,h=i.expando,l=n.nodeType,o=l?i.cache:n,f=l?n[h]:n[h]&&h;if(f&&o[f]&&(u||o[f].data)||void 0!==r||"string"!=typeof t)return f||(f=l?n[h]=c.pop()||i.guid++:h),o[f]||(o[f]=l?{}:{toJSON:i.noop}),("object"==typeof t||"function"==typeof t)&&(u?o[f]=i.extend(o[f],t):o[f].data=i.extend(o[f].data,t)),e=o[f],u||(e.data||(e.data={}),e=e.data),void 0!==r&&(e[i.camelCase(t)]=r),"string"==typeof t?(s=e[t],null==s&&(s=e[i.camelCase(t)])):s=e,s}}function wr(n,t,u){if(i.acceptData(n)){var o,s,h=n.nodeType,f=h?i.cache:n,e=h?n[i.expando]:i.expando;if(f[e]){if(t&&(o=u?f[e]:f[e].data)){for(i.isArray(t)?t=t.concat(i.map(t,i.camelCase)):(t in o)?t=[t]:(t=i.camelCase(t),t=(t in o)?[t]:t.split(" ")),s=t.length;s--;)delete o[t[s]];if(u?!ei(o):!i.isEmptyObject(o))return}(u||(delete f[e].data,ei(f[e])))&&(h?i.cleanData([n],!0):r.deleteExpando||f!=f.window?delete f[e]:f[e]=null)}}}function vt(){return!0}function it(){return!1}function dr(){try{return u.activeElement}catch(n){}}function gr(n){var i=nu.split("|"),t=n.createDocumentFragment();if(t.createElement)while(i.length)t.createElement(i.pop());return t}function f(n,t){var e,u,s=0,r=typeof n.getElementsByTagName!==o?n.getElementsByTagName(t||"*"):typeof n.querySelectorAll!==o?n.querySelectorAll(t||"*"):void 0;if(!r)for(r=[],e=n.childNodes||n;null!=(u=e[s]);s++)!t||i.nodeName(u,t)?r.push(u):i.merge(r,f(u,t));return void 0===t||t&&i.nodeName(n,t)?i.merge([n],r):r}function we(n){oi.test(n.type)&&(n.defaultChecked=n.checked)}function eu(n,t){return i.nodeName(n,"table")&&i.nodeName(11!==t.nodeType?t:t.firstChild,"tr")?n.getElementsByTagName("tbody")[0]||n.appendChild(n.ownerDocument.createElement("tbody")):n}function ou(n){return n.type=(null!==i.find.attr(n,"type"))+"/"+n.type,n}function su(n){var t=ve.exec(n.type);return t?n.type=t[1]:n.removeAttribute("type"),n}function li(n,t){for(var u,r=0;null!=(u=n[r]);r++)i._data(u,"globalEval",!t||i._data(t[r],"globalEval"))}function hu(n,t){if(1===t.nodeType&&i.hasData(n)){var u,f,o,s=i._data(n),r=i._data(t,s),e=s.events;if(e){delete r.handle;r.events={};for(u in e)for(f=0,o=e[u].length;o>f;f++)i.event.add(t,u,e[u][f])}r.data&&(r.data=i.extend({},r.data))}}function be(n,t){var u,e,f;if(1===t.nodeType){if(u=t.nodeName.toLowerCase(),!r.noCloneEvent&&t[i.expando]){f=i._data(t);for(e in f.events)i.removeEvent(t,e,f.handle);t.removeAttribute(i.expando)}"script"===u&&t.text!==n.text?(ou(t).text=n.text,su(t)):"object"===u?(t.parentNode&&(t.outerHTML=n.outerHTML),r.html5Clone&&n.innerHTML&&!i.trim(t.innerHTML)&&(t.innerHTML=n.innerHTML)):"input"===u&&oi.test(n.type)?(t.defaultChecked=t.checked=n.checked,t.value!==n.value&&(t.value=n.value)):"option"===u?t.defaultSelected=t.selected=n.defaultSelected:("input"===u||"textarea"===u)&&(t.defaultValue=n.defaultValue)}}function cu(t,r){var f,u=i(r.createElement(t)).appendTo(r.body),e=n.getDefaultComputedStyle&&(f=n.getDefaultComputedStyle(u[0]))?f.display:i.css(u[0],"display");return u.detach(),e}function yt(n){var r=u,t=ai[n];return t||(t=cu(n,r),"none"!==t&&t||(ot=(ot||i("